#include "admin.h"
#include "ui_admin.h"
#include"student.h"
#include"execsql.h"
#include"studentinfo.h"

#include <QSqlQueryModel>
#include<QMessageBox>
#include<QDebug>
#include"login.h"

Admin::Admin(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::Admin)
{
    ui->setupUi(this);
}

Admin::~Admin()
{
    delete ui;
}

void Admin::selectBoxSlot(QString A)//查询箱子状态
{ 

    bool ok = connectsqliteA.ok;
    if(ok)
    {
        QSqlQueryModel *model = new QSqlQueryModel(ui->tableView_A);

        model->setQuery(QString("select * from AdmintorInfoTable where ID = '%1';").arg(A));
        //列名
        model->setHeaderData(0, Qt::Horizontal, tr("ID"));
        model->setHeaderData(1, Qt::Horizontal, tr("Name"));
        model->setHeaderData(2, Qt::Horizontal, tr("Sex"));
        model->setHeaderData(3, Qt::Horizontal, tr("Birth"));
        model->setHeaderData(4, Qt::Horizontal, tr("loginpw"));
        model->setHeaderData(5, Qt::Horizontal, tr("face"));

        ui->tableView_A->setModel(model);//数据放置进去
        ui->tableView_A->verticalHeader()->hide();//不显示序号
    }
    else
    {
        QMessageBox::warning(this,"错误","未连接，请检查.");
    }
    A1 = A;
    qDebug()<<"A1="<<A1;
}
void Admin::slotforma()
{
    formAW->show();
    formAW->str = A1;
}

void Admin::slotchangeainfo()
{
    changea_infoAW->show();
    changea_infoAW->str = A1;
}

 void Admin::slotformakaoqin()
 {
     formakaoqinAW->show();
     formakaoqinAW->str = A1;
 }

  void Admin::slotformnew()
  {
      formnewW->show();
      formnewW->str = A1;
  }
void Admin::on_pb_forgetpswd_clicked()
{
    formAW = new FormA;
    connect(formAW,&FormA::signalforma,this,&Admin::slotforma);
    this->hide();
    formAW->showforma();
}

void Admin::on_pb_modifyinfo_clicked()
{
    changea_infoAW = new changeainfo;
    connect(changea_infoAW,&changeainfo::signalchangeainfo,this,
            &Admin::slotchangeainfo);
    this->hide();
     changea_infoAW->showchangeainfoW();
}

void Admin::on_pb_kaoqin_clicked()
{
    formakaoqinAW = new FormAkaoqin;
    connect(formakaoqinAW,&FormAkaoqin::signalformakaoqin,this,
            &Admin::slotformakaoqin);
    this->hide();
    formakaoqinAW->showformakaoqin();
}

void Admin::on_pb_holiday_clicked()
{
    pronew.startDetached("D:\\openmv\\bin\\openmvide.exe",QStringList());
        if(pronew.isOpen() == false)
        {
            pronew.close();
        }
}

 void Admin::showsaw()
 {
     emit signalsadmin();
     this->hide();
 }

void Admin::on_pb_rememberface_clicked()
{
    formnewW = new Formnew;
    connect(formnewW,&Formnew::signalformnew,this,&Admin::slotformnew);
    this->hide();
    formnewW->showformnew();
}
